<?php

class UseFulTools {
	public static function deleteDirectory($path) {
		$handle = opendir($path);
	    while ($f = readdir($handle)) {
	        if ($f != '.' && $f != '..') {
	        	$currentFile = $path . '/' . $f;
	            if (!is_dir($currentFile)) {
	                unlink($currentFile);
	            } else {
	                self::deleteDirectory($currentFile);
	            }
	        } // if
	    } // while
	    closedir($handle);
	    rmdir($path);
	}	
	
	public static function cleanDirectory($path) {
		$handle = opendir($path);
	    while ($f = readdir($handle)) {
	        if ($f != '.' && $f != '..') {
	        	$currentFile = $path . '/' . $f;
	            if (!is_dir($currentFile)) {
	                unlink($currentFile);
	            } else {
	                self::deleteDirectory($currentFile);
	            }
	        } // if
	    } // while
	    closedir($handle);
	}
}

 ?>